function gewDirectionalLight()
{
  this.type = GEW_DIRECTION_LIGHT;
  // Data map : direction(vec3),globalAmbient(vec3),lightColor(vec3), shadowStrength
  this.lightData = new WebGLFloatArray(10);
  this.viewMat = new gewMat4();
  this.projectionMat = new gewMat4();
  this.viewProjectionMat = new gewMat4();
  this.shadowMat = new gewMat4();
}

gewDirectionalLight.prototype = {
  setData: function(direction, ambient, color,shadowStrength)
  {
    direction.normalize();
    var lightData = this.lightData;
    lightData[0] = -direction.x;
    lightData[1] = -direction.y;
    lightData[2] = -direction.z;
    lightData[3] = ambient.x;
    lightData[4] = ambient.y;
    lightData[5] = ambient.z;
    lightData[6] = color.x;
    lightData[7] = color.y;
    lightData[8] = color.z;
    lightData[9] = shadowStrength;
  },
  setDirection:function(dir){
    dir.normalize();
    var lightData = this.lightData;
    lightData[0] = -direction.x;
    lightData[1] = -direction.y;
    lightData[2] = -direction.z;
  },
  setDirectionXYZ:function(x,y,z){
    var dir = gewRegVec0;
    dir.set(x,y,z);
    dir.normalize();
    var lightData = this.lightData;
    lightData[0] = -direction.x;
    lightData[1] = -direction.y;
    lightData[2] = -direction.z;
  },
  setAmbient:function(ambient){
    var lightData = this.lightData;
    lightData[3] = ambient.x;
    lightData[4] = ambient.y;
    lightData[5] = ambient.z;
  },
  setAmbientXYZ:function(r,g,b){
    var lightData = this.lightData;
    lightData[3] = r;
    lightData[4] = g;
    lightData[5] = b;
  },
  setColor:function(color){
    var lightData = this.lightData;
    lightData[6] = color.x;
    lightData[7] = color.y;
    lightData[8] = color.z;
  },
  setColorXYZ:function(r,g,b){
    var lightData = this.lightData;
    lightData[6] = r;
    lightData[7] = g;
    lightData[8] = b;
  },
  setShadowStrength:function(shadow_str){
    var lightData = this.lightData;
    lightData[9] = shadow_str;
  },
  getShadowStrength:function()
  {
    return this.lightData[9];
  },
  getDirection:function(result)
  {
    if(!result)
      result = new gewVec3();
    result.set(-this.lightData[0],-this.lightData[1],-this.lightData[2]);
    return result;
  },
  getAmbient:function(result)
  {
    if(!result)
      result = new gewVec3();
    result.set(this.lightData[3],this.lightData[4],this.lightData[5]);
    return result;
  },
  getColor:function(result)
  {
    if(!result)
      result = new gewVec3();
    result.set(this.lightData[6],this.lightData[7],this.lightData[8]);
    return result;
  }
}
